;;for trace functionality in drscheme
;;to trace a function (trace func-name)
;;to untrace (untrace func-name)
(require (lib "trace.ss"))

(define (first x) (car x))
(define (rest x) (cdr x))

(define (fibonacci-rec x) 
  (if (<= x 2) 1
      (+ (fibonacci-rec (- x 2)) 
         (fibonacci-rec (- x 1)))))

(define (factorial-rec x)
  (if (<= x 1) 
      1
      (* x (factorial-rec (- x 1)))))

(define (all-subsets x)
  (cond ((null? x) (list x))
        (else 
         (let ((right-subsets (all-subsets (rest x))))
           (append right-subsets
                   (map (lambda (y) (cons (first x) y)) right-subsets))))))